$(function() {

	//ztree
	var setting = {
		check: {
			enable: true,
			chkDisabledInherit: true
		},
		data: {
			simpleData: {
				enable: true
			}
		}
	};

	var zNodes = {$zTree};

	$.fn.zTree.init($("#ztreeid"), setting, zNodes);
	$("#addmenu").on('click', function() {
		var treeObj = $.fn.zTree.getZTreeObj("ztreeid");
		var nodes = treeObj.getNodes();
		console.log(nodes);
		var text = [];
		for(var i = 0; i < nodes.length; i++) {
		if(nodes[i].checked) {text.push(nodes[i].id)}
			if(nodes[i].children) {
				for(var j = 0; j < nodes[i].children.length; j++) {
					if(nodes[i].children[j].checked) {text.push(nodes[i].children[j].id)}
					if(nodes[i].children[j].children) {
						for(var z = 0; z < nodes[i].children[j].children.length; z++) {
							if(nodes[i].children[j].children[z].checked) {text.push(nodes[i].children[j].children[z].id)}
						}
					} 
				}
			} 
		}
		console.log(text)
		$('.menus').val(text)
		console.log($('.menus').val())
		var arr = [];
		var panduan = 1;
		sendForm($(this));
		//		window.location.href = "/admin/menu/index";
	})
})

function chang(a) {
	if(a.value != 0) {

		$(a).parent().next().html("");
	} else {

	}
}